﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ShadowCommando.Game.Elements;
using System.Configuration;
using System.Windows.Forms;
using ShadowCommando.Game.Utilites;
namespace ShadowCommando.Game.Elements.Obstacle
{
    /// <summary>
    /// Klasa reprezentująca przeszkode
    /// </summary>
   public class Obstacle:Element
   {
       private Dictionary<ObstacleId, ApplicationSettingsBase> infoDictionary;
       /// <summary>
       /// Konstruktor
       /// </summary>
       /// <param name="_step">Krok</param>
       /// <param name="_diff">Poziom trudności</param>
       /// <param name="_obstacleId">Id przeszkody</param>
        public Obstacle(int _step,LevelDifficulty _diff,ObstacleId _obstacleId):base(_step,_diff)
        {
            obstacleId = _obstacleId;
            elementId = ElementId.Obstacle;
            InitInfoDictionary();
            LoadSettings(infoDictionary[obstacleId]);
            zIndex = -1;
//            Create(obstacleId);
        }
        #region Items

        private ObstacleId obstacleId;

        #endregion
        /// <summary>
        /// Id przeszkody
        /// </summary>
        public ObstacleId ObstacleId
        {
            get { return obstacleId; }
            set { obstacleId = value; }
        }
        #region Functions
     
      
        private void InitInfoDictionary()
        {
            infoDictionary=new Dictionary<ObstacleId, ApplicationSettingsBase>();
            infoDictionary.Add(Elements.ObstacleId.Building,Building1Info.Default);
            infoDictionary.Add(Elements.ObstacleId.Building2, Building1Info.Default);
            infoDictionary.Add(Elements.ObstacleId.Wall,WallInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Lake1,LakeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree1,TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Leaf1,LeafInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree2, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree3, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree4, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree5, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree6, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Tree7, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm1, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm2, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm3, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm4, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm5, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Palm6, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Branch1, BranchInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Branch2, BranchInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Branch3, BranchInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Branch4, BranchInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Laboratory, Building1Info.Default);
            infoDictionary.Add(Elements.ObstacleId.Ice1, IceInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Ice2, IceInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Ice3, IceInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Ice4, IceInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Ice5, IceInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Snow1, SnowInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Snow2, SnowInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.SnowTree1, TreeInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone1, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone2, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone3, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone4, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone5, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Stone6, StoneInfo.Default);

            infoDictionary.Add(Elements.ObstacleId.Factory, Building1Info.Default);
            infoDictionary.Add(Elements.ObstacleId.Rock1, StoneInfo.Default);
            infoDictionary.Add(Elements.ObstacleId.Rock2, StoneInfo.Default);
            //zmienic
            infoDictionary.Add(Elements.ObstacleId.Dune1, SnowInfo.Default);

        }
        private void LoadSettings(ApplicationSettingsBase asb)
        {
            Movable =(bool)asb["Movable"];
            Shootable =(bool) asb["Shootable"];
            DestroyAble = (bool) asb["Destroyable"];
            Immortal = (bool) asb["Immortal"];
            Life = (int) asb["Life"];
            Points = (int) asb["Points"];
            Kind = (string) asb["Kind"];

        }
        #endregion
    }
}
